package com.yunb.service;


import com.yunb.entity.Basic;
import com.yunb.util.JedisUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;


@Service
public class RedisRedWarsServiceImpl implements RedisRedWarsService {

	@Resource
	private GenRedPack genRedPack;

	@Resource
	private GetRedPack getRedPack;

	@Override
	public void qianghongbao() throws Exception{

		genRedPack.genHongBao();//初始化红包

		System.out.println("------------------红包初始化完成，开始抢红包------------------");
		Thread.sleep(5000);

		getRedPack.getHongBao();//从红包池抢红包
	}

	@Override
	public void initRedBao() throws Exception {

		genRedPack.initRedBao();//模仿自己发红包，初始化 要求线程数和红包数一致，才可以玩转

		System.out.println("------------------红包初始化完成，开始抢红包------------------");
		System.out.println("------------------------总金额："+ Basic.moneyTotal +"------------------");
		System.out.println("------------------------第 "+ Basic.playnum +" 次------------------");
		//getRedPack.getHongBao();//从红包池抢红包
		getRedPack.playSelfRedWar();//从红包池抢红包
		Basic.playnum.addAndGet(1);
	}

} 
